function GetQueryString(name) {
    var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)");
    var r = window.location.search.substr(1).match(reg);
    if (r != null) return unescape(r[2]); return null;
}

butt_id = GetQueryString('butt_id');

// 获取指定用户列表
function getUsersList(callback) {
    $.ajax({
        dataType: "JSON",
        type: "post",
        data:{butt_id:butt_id},
        url: '/admin/chat_monitor/getAppointUsersList.html',
        success: function (res) {
            callback(res)
        }
    })
}

//获取聊天记录
function getChatLog(butt_id,openid,callback){
    $.ajax({
        dataType: "JSON",
        type: "post",
        data:{butt_id:butt_id,openid:openid},
        url: '/admin/chat_monitor/getAppointUserChat.html',
        success: function (res) {
            callback(res)
        }
    })
}

// 分页函数
function setPage(el, data, callback){
    console.log(data)
    window[el] = new iPage({
        elem: '#'+el,
        limit: 8, //分页数
        curr: 1, //初始页
        count: data.length, //数据总数,
        hidenum: 10,
        topages: true,
        jump: function(obj, first){
            callback(obj, first)
            console.log(obj)
        }
    });
}


function formatDate(date, fmt) {
        if (/(y+)/.test(fmt)) {
            fmt = fmt.replace(RegExp.$1, (date.getFullYear() + '').substr(4 - RegExp.$1.length))
        }
        let o = {
            'M+': date.getMonth() + 1,
            'd+': date.getDate(),
            'h+': date.getHours(),
            'm+': date.getMinutes(),
            's+': date.getSeconds()
        }
        for (let k in o) {
            if (new RegExp(`(${k})`).test(fmt)) {
                let str = o[k] + ''
                fmt = fmt.replace(RegExp.$1, (RegExp.$1.length === 1) ? str : padLeftZero(str))
            }
        }
        return fmt
    }
function padLeftZero(str) {
    return ('00' + str).substr(str.length)
}